package com.ticket.sass.admin.dto.output.config;

import com.ticket.sass.common.entity.tenant.TicketRefundConfigEntity;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import java.util.ArrayList;
import java.util.List;

/**
 * @author ywb
 * @date 2024-03-24 17:34
 */
@Data
@ApiModel
public class TicketRefundConfigOutput {
    @ApiModelProperty(value = "退改类型：1退票，2改签")
    private Short type;
    
    @ApiModelProperty(value = "是否启用")
    private Boolean enable;
    
    @ApiModelProperty(value = "每月可退改次数，-1 无限，> -1 指定次数")
    private Integer max;
    
    @ApiModelProperty(value = "说明")
    private String instructions;
    
    @ApiModelProperty(value = "退票规则")
    private List<TicketRefundRuleOutput> ticketRefundRules;
    
    public TicketRefundConfigOutput() {
    }
    
    public TicketRefundConfigOutput(Short type) {
        this.type = type;
        this.enable = false;
        instructions = "";
        max = -1;
        ticketRefundRules = new ArrayList<>();
    }
    
    public TicketRefundConfigOutput(TicketRefundConfigEntity config) {
        this.type = config.getType().getValue();
        this.enable = config.getEnable();
        this.max = config.getMax();
        this.instructions = config.getInstructions();
    }
}
